import request from '@/utils/request'

//创建技能培训文章
export const createTrainingService = ({
  title,
  fileUrl,
  imageUrl,
  description,
  tag
}) =>
  request.post('/web/admin/skill/create', {
    title,
    fileUrl,
    imageUrl,
    description,
    tag
  })

//分页查询所有的文章
export const getTrainingListService = ({
  title,
  activeStatus,
  deleted,
  pageNo,
  pageSize
}) => {
  const params = {
    title,
    activeStatus,
    deleted,
    pageNo,
    pageSize
  }
  if (!params.title) delete params.title
  if (!params.activeStatus) delete params.activeStatus
  if (!params.deleted) delete params.deleted
  return request.get('/web/admin/skill/getAll', {
    params: params
  })
}

//根据id查询文章
export const getTrainingByIdService = (id) =>
  request.get(`/web/admin/skill/${id}`)

//管理员更新技能培训文档
export const updateTrainingService = ({
  id,
  title,
  fileUrl,
  imageUrl,
  description,
  tag,
  activeStatus,
  deleted
}) =>
  request.put('/web/admin/skill/update', {
    id,
    title,
    fileUrl,
    imageUrl,
    description,
    tag,
    activeStatus,
    deleted
  })
